import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/pages/my/controller/fix_password_ctr.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

///修改密码
class UpdatePassword extends GetView<FixPasswordController> {
  const UpdatePassword({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<FixPasswordController>(builder: (controller){
      return BasePage(
        title: controller.pageTitle,
        iconType: IconType.back,
        isShowPadding: true,
        children: [
          controller.step==1?
            phoneVerfity():
           controller.type==0?  
            passsBox():
            payPasswordBox()
        ],
      );
    });
  }


  //验证码
  Widget phoneVerfity(){
    return Container(
          padding: EdgeInsets.all(18.w),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const SizedBox(
                    child: Text("请完成以下认证"),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 10.w),
                    child: Text("请输入 ${controller.encodePhoneNumber} 收到的验证码"),
                  ),
                ],
              ),
              
              Container(
                margin: EdgeInsets.only(top: 15.w),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Container(
                      width: 180.w,
                      height: 40.h,
                      padding: EdgeInsets.only(left: 8.w, top: 10.w),
                      color: Colors.white,
                      child: TextFormField(
                        controller: controller.vertifyTxtCtr,
                        decoration: descript("请输入手机验证码"),
                        textAlign: TextAlign.left,
                      ),
                    ),
                    SizedBox(
                      width: 120.w,
                      height: 38.h,
                      child: solidButton(fontsize: 11, backgroundColor: controller.buttonColor , controller.countdownTxt, () {
                        controller.sendVerfityCode();
                      },radius: 10),
                    )
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 30.w),
                child: solidButton("下一步", () {
                  controller.submit();
                },radius: 10),
              )
            ],
          ),
        );
  }

  //修改密码输入框
  Widget passsBox(){
    return Container(
          padding: EdgeInsets.all(18.w),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                margin: EdgeInsets.only(bottom: 10.w),
                child: Text("设置新的登录密码",style: blackFont(14),),
              ),
              Container(
                padding: EdgeInsets.all(10.w),
                color: Colors.white,
                child: TextFormField(
                  decoration: descript("请输入8~10位数字/字母/字符组合"),
                  controller: controller.passwordTxt,
                  textAlign: TextAlign.left,
                  autofocus: true,
                  obscureText: true,
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 60.w),
                child: solidButton("确认", () {
                  controller.submit();
                 },radius: 10),
              )

            ],
          ),
        );
  }


  //支付密码输入框
  Widget payPasswordBox(){
    return Container(
          padding: EdgeInsets.all(18.w),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                margin: EdgeInsets.only(bottom: 10.w),
                child: Text("新的支付密码",style: blackFont(14),),
              ),
              Container(
                color: Colors.white,
                padding: EdgeInsets.all(10.w),
                child: TextFormField(
                  controller: controller.passwordTxt,
                  obscureText: true,
                  decoration: descript("请输入新支付密码"),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top:20.w, bottom: 10.w),
                child: Text("二次确认支付密码",style: blackFont(14),),
              ),
              Container(
                color: Colors.white,
                padding: EdgeInsets.all(10.w),
                child: TextFormField(
                  controller: controller.confirmPasswordTxt,
                  obscureText: true,
                  decoration: descript("请再次输入新支付密码"),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 60.w),
                child: solidButton("确认", () {
                  controller.submit();
                 },radius: 10),
              )

            ],
          ),
        );
  }
}